import java.util.concurrent.Callable;

/* 1. 接口定义计算面积和周长方法；
2. 定义图形抽象类包含图形名称属性及显示图形名称的抽象方法；
3. 定义圆类和矩形类继承图形类并实现接口中计算面积和周长的方法；
4. 定义功能类，根据不同的形状实现对面积和周长的计算以及显示输出该图形名称的方法；
5. 主方法中测试各功能。
 * */
interface I{
    public abstract double claculateS();
    double calculateT();
}
abstract class Shape{
    private String name;
    public abstract void show();

    public Shape(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
class Cycle extends Shape implements I{
    private int r;

    public Cycle(String name, int r) {
        super(name);
        this.r = r;
    }

    public int getR() {
        return r;
    }

    public void setR(int r) {
        this.r = r;
    }


    public void show(){
        System.out.println(this.getName()+"半径:"+r+"面积："+claculateS()+"周长:"+calculateT());
    }

    @Override
    public double claculateS() {
        return 3.14*r*r;
    }

    @Override
    public double calculateT() {
          return 2*3.14*r;
    }
}
class A extends Shape implements I{
    private int a;
    public int b;

    public A(String name, int a, int b) {
        super(name);
        this.a = a;
        this.b = b;
    }

    public void show(){
        System.out.println(this.getName()+"长: "+a+"宽: "+b+"面积: "+claculateS()+"周长: "+calculateT());
    }

    @Override
    public double claculateS() {
      return a*b;
    }

    @Override
    public double calculateT() {
        return 2*(a+b);
    }
}
public class Test {
    public static void main(String[] args) {
     Cycle cycle=new Cycle("圆",4);
     A a=new A("矩形",2,3);
     System.out.println(cycle.claculateS());
     System.out.println(cycle.calculateT());
     cycle.show();
     System.out.println(a.claculateS());
     System.out.println(a.calculateT());
     a.show();
    }
}
